package com.raidan.dclog.core.parser;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import com.raidan.dclog.core.Database;

/**
 * Parser core. Simple class with simple work.
 * 
 * @author raidan
 */
public class ParserCore {

	public void parse(Connection connection) throws SQLException, IOException, ParseLineException {
		try {

			Database.getInstance().clearDatabase();

			for (IParser instance : ParserFactory.getParsers()) {
				instance.parse(connection);
			}

			// Don't forget to say -- we success ^_^
			Database.getInstance().confirmDatabaseOK();

		} catch (SQLException sql) {
			connection.rollback();
			throw sql;
		}
	}
}
